<template>
    <div class="UserList-view">
        <el-table
                :data="contentlist"
                border
                :fit="fittrue"
                style="width: 100%"
                @selection-change="changeFun">
            <el-table-column v-if="headlist.checkout==true"
                    type="selection"
                    width="50">
            </el-table-column>
            <el-table-column
                    v-for="item in headlist.list"
                    :key=" item.id"
                    :prop="item.prop"
                    :label="item.label"
                    :width="item.width"
                    :formatter="item.formatter?item.formatter:undefined">
            </el-table-column>
            <el-table-column
                    v-if="headlist.operation.type==true"
                    label="操作"
                    min-width="200">
                <template slot-scope="scope">
                    <div  v-if="headlist.operation.fromurl=='structManage'">
                        <el-button type="text" size="small" @click="seeDetailsOrganization(scope.row)">查看</el-button>
                        <el-button type="text" size="small" @click="editDetails(scope.row)">编辑</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='memberManage'">
                        <el-button @click="editUserinfo(scope.row,1)" type="text" size="small">查看</el-button>
                        <el-button type="text" size="small" @click="editUserinfo(scope.row,2)">编辑</el-button>
                        <el-button type="text" size="small" @click="editUserinfo(scope.row,3)">拓展二维码</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='rolePemission'">
                        <el-button type="text" size="small" @click="editRole(scope.row)">编辑</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='projectResident'">
                        <el-button type="text" size="small" @click="editResident(scope.row)">编辑</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='agentManage'">
                        <el-button type="text" size="small" @click="seeAgenter(scope.row)">查看</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='reportClients'">
                        <el-button type="text" size="small" @click="goinfollowUp(scope.row)">跟进</el-button>
                    </div>
                    <div  v-if="headlist.operation.fromurl=='houseManage'">
                        <el-button type="text" size="small" @click="goinseeHouse(scope.row)">查看</el-button>
                        <el-button type="text" size="small" @click="goineditHouse(scope.row)">编辑</el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <addForm :seeDetails="rowDetails" :dialogFormVisible="showDetails" @close="closeForm"></addForm>
        <seeOrganization :seeDetails="rowOrganization" @openOrgEdit="openOrgEdit"  :dialogFormVisible="showOrganization" @close="close0rganization"></seeOrganization>
        <addRole :seeDetails="roleDetails" :dialogFormVisible="showrole" @close="closeFormrole"></addRole>
        <addResident :seeDetails="residentDetails" :dialogFormVisible="showResident" @close="closeFormResident"></addResident>
        <!--查看经纪人-->
        <seeAgents :dialogFormVisible="showseeAgents" :seeDetails="agentermsg" @close="closeseeAgents"></seeAgents>
        <!--查看跟进-->
        <followUp :dialogFormVisible="showfollowUp" :seeDetails="followUpmsg" @close="closefollowUp"></followUp>
        <!--查看用户-->
        <addUser :dialogFormVisible="showadduser" :seeDetails="userDetails" @refreshList="refreshList" :comeRrom="comeRrom" @close="closeAddUser"></addUser>
    </div>
</template>

<script>
    import addForm from '../../common/Dialog/addForm';
    import addRole from '../../common/Dialog/addRole';
    import addResident from '../../common/Dialog/addResident';
    import seeAgents from '../../common/Dialog/seeAgents';
    import followUp from '../../common/Dialog/followUp';
    import addUser from '../../common/Dialog/addUser';
    import seeOrganization from '../../common/Dialog/seeOrganization';
    export default {
        name: "UserList",
        props: {
            headlist:{
                type:Object,
                required:true,
            } ,
            contentlist:{
                type:Array,
                required:true,
            },
        },
        components: {
            addForm,
            addRole,
            addResident,
            seeAgents,
            followUp,
            addUser,
            seeOrganization
        },
        mounted(){
            console.log("wwwwwww",this.headlist.checkout)
        },
        methods: {

            refreshList(){
                this.$emit("refreshContentList");
            },

            //打开组织机构编辑
            openOrgEdit(clildSendValue){
                debugger
                this.editDetails(clildSendValue)
            },
            //编辑组织
            editDetails(row){
                this.rowDetails=row;
                this.showDetails=true
            },
           goineditHouse(row){
               this.$emit("houseViewShowedit",row.linkerId);
           },
            //查看楼盘信息
            goinseeHouse(row){
                this.$emit("houseViewShow",row.linkerId);
            },
            //跟进报备
            closefollowUp(){
                this.showfollowUp=false
            },
            goinfollowUp(row){
                this.showfollowUp=true
                this.followUpmsg=row
            },
            //关闭按钮
            closeseeAgents(){
                this.showseeAgents=false
            },
            //查看经纪人
            seeAgenter(row){
                this.showseeAgents=true
                this.agentermsg=row
            },
            changeFun (val) {
                // 返回的是选中的列的数组集合
                let multipleSelection= val.map(item=>item.id+"")
                let list = multipleSelection.join(",")
                this.$emit("selectList",list);
                // console.log("???????????",list)
            },
            //编辑项目驻场
            editResident(row){
                this.residentDetails=row;
                this.showResident=true
            },
            closeFormResident(){
                this.showResident=false;
                this.residentDetails={}
            },
            //编辑角色
            editRole(row){
                this.roleDetails=row;
                this.showrole=true
            },
            closeFormrole(){
                this.showrole=false;
                this.roleDetails={}
            },
            handleClick(row) {
                console.log(row,"eeeeeeee");
            },
            closeForm(){
                this.showDetails=false;
                this.rowDetails={}
            },
            // //查看组织结构
            seeDetailsOrganization(row){
               console.log("啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊")
                this.rowOrganization=row;
                this.showOrganization=true
                console.log("111111")
            },
            close0rganization(){
                this.showOrganization=false;
                this.rowOrganization={}
            },

            //查看组织结构
            //编辑用户
            editUserinfo(row,type){
                this.userDetails=row;
                this.comeRrom=type
                this.showadduser=true
                console.log("111111")
            },
            closeAddUser(){
                this.showadduser=false;
                this.userDetails={}
            }
        },
        data() {
            return {
                fittrue:true,
                tablelist:this.contentlist,
                rowDetails:{},
                showDetails:false,
                roleDetails:{},
                showrole:false,
                residentDetails:{},
                showResident:false,
                multipleSelection:"",
                showseeAgents:false,
                agentermsg:{},
                showfollowUp:false,
                followUpmsg:{},
                showadduser:false,
                userDetails:{},
                comeRrom:0,
                rowOrganization:{},
                showOrganization:false
            }
        }
    }
</script>
<style  rel="stylesheet/scss" lang="scss" >
    .UserList-view{
    .el-table--border td, .el-table--border th {
        border-right:none;
    }
        .el-table td, .el-table th.is-leaf {
            border-bottom: 1px solid #E8E8E8
        }
        .el-table tr {
            background-color: #fff;
            height: 53px;
        }
        .el-table__fixed, .el-table__fixed-right {
             box-shadow: none;
        }
        .el-table {
            /*border:none;*/
        }
    }
</style>
<style  rel="stylesheet/scss" lang="scss"  scoped>
.UserList-view{
    font-size:14px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:rgba(0,0,0,0.65);
}
</style>